package cn.tedu.d1_thread;

 /**多线程案例实践：
 * 4个售票窗口，总计100张
  * 方法二
 * */

public class Test4_SaleTickets {
    public static void main(String[] args) {
        TicketsRunnable target=new TicketsRunnable();

        Thread t1=new Thread(target,"一号窗口");
        Thread t2=new Thread(target,"二号窗口");
        Thread t3=new Thread(target,"三号窗口");
        Thread t4=new Thread(target,"四号窗口");

        t1.start();t2.start();t3.start();t4.start();


    }
}

class TicketsRunnable implements Runnable{

    static int ticket=100;

    @Override
    public void run() {

        while (true){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()
                    +"="+ticket--);
            if(ticket<=0) break;
        }
    }
}
